package com.tianji.promotion.handler;


import com.tianji.promotion.service.ICouponService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Component
@RequiredArgsConstructor
@Slf4j
public class PromotionHandler {
    private final ICouponService couponService;

    /**
     * 定时任务：定时开始发放优惠券
     */
    @XxlJob("sendCoupon")
    public void sendCoupon(){
        couponService.updateUnissuedCouponStatus(true);
        log.info("定时发放优惠券");
    }
    /**
     * 定时任务：定时结束发放优惠券
     */
    @XxlJob("endCoupon")
    public void endCoupon(){
        couponService.updateUnissuedCouponStatus(false);
        log.info("定时发放优惠券");
    }

}
